package com.asset.dispoal.business.bsAssetInstitutionBatch.service.commom;

import com.asset.dispoal.business.bsAssetInstitutionBatch.domain.db.entity.BsAssetInstitutionBatch;
import com.asset.dispoal.business.bsAssetInstitutionBatch.domain.db.mapper.BsAssetInstitutionBatchMapper;
import com.asset.dispoal.business.bsAssetInstitutionBatch.dto.BsAssetInstitutionPolicyResponse;
import com.asset.dispoal.business.bsAssetInstitutionBatch.service.converter.BsAssetInstitutionBatchConverter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import tech.mhuang.pacebox.core.ddd.BaseCommand;
import tech.mhuang.pacebox.springboot.protocol.Result;

/**
 * @author: yf
 * @date: 2022-08-17 09:14:05
 */
@Component
public class QueryPolicyByIdCommand implements BaseCommand<String, Result<BsAssetInstitutionPolicyResponse>> {
    @Autowired
    BsAssetInstitutionBatchMapper bsAssetInstitutionBatchMapper;

    @Override
    public Result<BsAssetInstitutionPolicyResponse> execute(String id) {
        BsAssetInstitutionBatch policy = bsAssetInstitutionBatchMapper.getById(id);
        BsAssetInstitutionPolicyResponse policyResponse = BsAssetInstitutionBatchConverter.INSTANCE.doToRes(policy);

        return Result.ok(policyResponse);
    }
}
